package com.example.javabasic.suanfa.剑指offer.跳台阶;

/**
 * @description 跳台阶  一次可以条1层或者2层,  求n阶 有多少种跳法
 * @Author Lin FuYuan
 * @date 2021/7/8
 */
public class Solution {

    public int jumpFloor(int target) {
        // target = 1  返回1
        //target = 2 返回2
        //target = 3 返回 3;
        //target = 4 返回 5
        // f(4) = f(2)+ f(3);
        if(target<= 3){
            return target;
        }
        int f1;
        int f2 = 2;
        int f3 = 3;
        for (int i = 4; i <= target; i++) {
            f1 = f2;
            f2 = f3;
            f3  = f1+f2;
        }
        return f3;
    }
}
